#include<stdio.h>
int a[8]={8,6,2,3,1,5,7,4};

void sort( int a[8] , int left , int right , int mid )
{
	int temp[8]={0};
	int l=left,r=right , t=l , k=mid;
	if(l>=r)
		return ;
	while( l!=mid && k!=r+1 )
	{
		if( a[l] > a[k] )
			temp[t++]=a[k++];
		else
			temp[t++]=a[l++];
	}
	
	while( k!=r+1 )
		temp[t++]=a[k++];
	while( l!=mid )
		temp[t++]=a[l++];
	
	for(t=left;t<=right;t++)
		a[t]=temp[t];
	
	return ;
}
void mergesort(int a[8] , int left , int right )
{
	//int l=left , r=right ;
	int mid=(left+right)/2+1;
	if(left>=right)
		return ;
	mergesort( a , left , mid-1);
	mergesort( a ,  mid , right );
	sort( a , left , right , mid );
}

int main()
{
	int left=0,right=7;
	mergesort( a , left , right );
	for(int i=0 ; i<8 ; i++)
		printf("%d",a[i]);
	printf("\n");
	return 0;
}
